package servlet.zj;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.DAOFactory;
import dao.zj.BrandDao;
import entity.Brand;

/**
 * Servlet implementation class AddBrand
 */
@WebServlet("/AddBrand")
public class AddBrand extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private BrandDao two=DAOFactory.createBrandDAO();
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		Brand one=new Brand();
		String name=request.getParameter("brand_name");
		one.setBrandName(request.getParameter("brand_name"));
		one.setBrandUrl(request.getParameter("brand_url"));
		one.setBrandDescribe(request.getParameter("brand_desc"));
		boolean x=two.addbrand(one);
		String url=x?"jump3.jsp?brandName=":"jump4.jsp?brandName=";
		request.getRequestDispatcher(url+name).forward(request, response);
	}
}
